const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const webpack  = require("webpack")
module.exports  = {
    mode:"development",
    entry:"./src/main.js",
    // output:{
    //     filename:"bundle.js",
    //     path:path.resolve(__dirname,"dist"),
    //     publicPath:"/assets/"  //输出项目所有静态资源都放在/publicPath + 文件路径
    // },
    devServer:{
        publicPath:"/assets/", //所有打包文件所放根路劲
        // port:3000,
        compress:true,//一切服务都启用gzip压缩
        contentBase:path.join(__dirname,"src"),
        // hot:true,//热更新
        open:true//打开浏览器
        
    },
    module:{
        rules:[
             {
                test: /\.html$/,
                use: ['html-loader']
              },
              {
                  test:/\.(png|gif|jpg)/,
                  exclude:/node_modules/,
                  use:[
                      {
                        loader: 'url-loader',
                        options:{
                            limit:2*1024,
                            name:"img/[name].[hash:6].[ext]"
                        }
                    }]
              }
        ]
    },
    plugins:[
        new HtmlWebpackPlugin({
            template:"./src/index.html",
            filename:"index.html"
        }),
        new webpack.HotModuleReplacementPlugin()
    ]
}